package com.example.view.module.event;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import androidx.appcompat.widget.ActivityChooserView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.example.common.base.AbsActivity;
import com.example.view.R;
import com.example.view.databinding.ActEventCaseBinding;

@Route(path = "/event/case")
public class EventCaseActivity extends AbsActivity<ActEventCaseBinding> {

    private int[] ids = {R.mipmap.girl1, R.mipmap.girl2, R.mipmap.girl3, R.mipmap.girl4};

    @Override
    protected int getLayoutId() {
        return R.layout.act_event_case;
    }

    @Override
    protected void main() {
        mBinding.listView1.setAdapter(new MyAdapter());
        mBinding.listView2.setAdapter(new MyAdapter());
        mBinding.listView3.setAdapter(new MyAdapter());
    }

    @Override
    protected void initListener() {

    }

    private class MyAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            return 100;
        }

        @Override
        public Object getItem(int position) {
            return ids[position];
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ViewHolder viewHolder;
            if (convertView == null) {
                convertView = ActivityChooserView.InnerLayout.inflate(mContext, R.layout.item_image, null);
                viewHolder = new ViewHolder();
                viewHolder.imageView = convertView.findViewById(R.id.imageView);
                convertView.setTag(viewHolder);
            } else {
                viewHolder = (ViewHolder) convertView.getTag();
            }
            viewHolder.imageView.setImageResource(ids[(int) (Math.random() * 4)]);
            return convertView;
        }
    }

    private class ViewHolder {
        private ImageView imageView;
    }
}
